/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Forms;

import BLL.BLLBenhNhan;
import BLL.BLLPhongKham;
import DTO.DTOBenhNhan;
import DTO.DTOPhongKham;
import java.awt.HeadlessException;
import java.awt.event.KeyEvent;
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;

/**
 *
 * @author Documents
 */
public class DangKyKhamBenh extends javax.swing.JFrame {
    BLLPhongKham bllPhongKham = new BLLPhongKham();
    BLLBenhNhan bllBenhNhan = new BLLBenhNhan();
    /**
     * Creates new form DangKyKhamBenh
     */
    public DangKyKhamBenh() {
        initComponents();
        //hiển thị người đăng nhập sử dụng phần mềm
        jtextfNhanvientruc.setText(MainMenu.dtoNguoiDung.getDtoNV().getHoTen());
        
        //khởi tạo các phòng khám vào combobox
        DefaultComboBoxModel modelPhong = new DefaultComboBoxModel();
        for(DTOPhongKham dtoPhong : bllPhongKham.layDSPhongKham()){
            modelPhong.addElement(dtoPhong);
        }
        jcbPhongKham.setModel(modelPhong);
        
        //hiển thị ngày hiện tại
        SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");
        java.util.Date date = new java.util.Date();
        String currentDate = format.format(date);
        lbdate.setText(currentDate);
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jtextfMabn = new javax.swing.JTextField();
        jtextfTen = new javax.swing.JTextField();
        jtextfDienthoai = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jcbNamsinh = new javax.swing.JComboBox();
        jtextfDiachi = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jrdNam = new javax.swing.JRadioButton();
        jrdNu = new javax.swing.JRadioButton();
        jLabel13 = new javax.swing.JLabel();
        jrdCobh = new javax.swing.JRadioButton();
        jrdKhongbh = new javax.swing.JRadioButton();
        jlbMabh = new javax.swing.JLabel();
        jtextfMabh = new javax.swing.JTextField();
        jcheckboxVuottuyen = new javax.swing.JCheckBox();
        jtextfTuoi = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jtextfCmnd = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jcbNgayHH = new javax.swing.JComboBox();
        jcbThangHH = new javax.swing.JComboBox();
        jcbNamHH = new javax.swing.JComboBox();
        jPanel2 = new javax.swing.JPanel();
        jLabel18 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtextaTiensu = new javax.swing.JTextArea();
        jPanel3 = new javax.swing.JPanel();
        jLabel19 = new javax.swing.JLabel();
        jcbPhongKham = new javax.swing.JComboBox();
        jPanel4 = new javax.swing.JPanel();
        jLabel25 = new javax.swing.JLabel();
        jtextfNhanvientruc = new javax.swing.JTextField();
        lbdate = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        btnSave = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(0, 102, 0));
        jLabel1.setText("ĐĂNG KÝ KHÁM BỆNH");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(0, 51, 102)), "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, new java.awt.Color(0, 51, 102)));

        jLabel2.setText("Mã BN");

        jLabel3.setText("Họ tên");

        jLabel4.setText("Điện thoại");

        jLabel5.setText("Địa chỉ");
        jLabel5.setToolTipText("");

        jtextfMabn.setEnabled(false);
        jtextfMabn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtextfMabnActionPerformed(evt);
            }
        });
        jtextfMabn.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtextfMabnKeyReleased(evt);
            }
        });

        jtextfTen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtextfTenActionPerformed(evt);
            }
        });
        jtextfTen.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtextfTenKeyReleased(evt);
            }
        });

        jtextfDienthoai.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtextfDienthoaiKeyTyped(evt);
            }
        });

        jLabel7.setText("Năm sinh");

        jcbNamsinh.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1914", "1915", "1916", "1917", "1918", "1919", "1920", "1921", "1922", "1923", "1924", "1925", "1926", "1927", "1928", "1929", "1930", "1931", "1932", "1933", "1934", "1935", "1936", "1937", "1938", "1939", "1940", "1941", "1942", "1943", "1944", "1945", "1946", "1947", "1948", "1949", "1950", "1951", "1952", "1953", "1954", "1955", "1956", "1957", "1958", "1959", "1960", "1961", "1962", "1963", "1964", "1965", "1966", "1967", "1968", "1969", "1970", "1971", "1972", "1973", "1974", "1975", "1976", "1977", "1978", "1979", "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014" }));
        jcbNamsinh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbNamsinhActionPerformed(evt);
            }
        });

        jtextfDiachi.setAutoscrolls(false);
        jtextfDiachi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtextfDiachiActionPerformed(evt);
            }
        });

        jLabel8.setText("Tuổi");

        jLabel10.setText("Giới tính");

        buttonGroup1.add(jrdNam);
        jrdNam.setText("Nam");
        jrdNam.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jrdNamActionPerformed(evt);
            }
        });

        buttonGroup1.add(jrdNu);
        jrdNu.setText("Nữ");

        jLabel13.setText("BHYT");

        buttonGroup2.add(jrdCobh);
        jrdCobh.setText("Có");
        jrdCobh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jrdCobhActionPerformed(evt);
            }
        });

        buttonGroup2.add(jrdKhongbh);
        jrdKhongbh.setText("Không");
        jrdKhongbh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jrdKhongbhActionPerformed(evt);
            }
        });

        jlbMabh.setText("Mã BHYT");

        jtextfMabh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtextfMabhActionPerformed(evt);
            }
        });
        jtextfMabh.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtextfMabhKeyPressed(evt);
            }
        });

        jcheckboxVuottuyen.setText("Vượt tuyến");
        jcheckboxVuottuyen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcheckboxVuottuyenActionPerformed(evt);
            }
        });

        jtextfTuoi.setEnabled(false);
        jtextfTuoi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtextfTuoiActionPerformed(evt);
            }
        });

        jLabel9.setText("CMND");

        jtextfCmnd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtextfCmndActionPerformed(evt);
            }
        });
        jtextfCmnd.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtextfCmndKeyTyped(evt);
            }
        });

        jLabel12.setText("Ngày hết hạn");

        jcbNgayHH.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));
        jcbNgayHH.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcbNgayHHItemStateChanged(evt);
            }
        });
        jcbNgayHH.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbNgayHHActionPerformed(evt);
            }
        });

        jcbThangHH.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }));

        jcbNamHH.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2014", "2015", "2016", "2017", "2018" }));
        jcbNamHH.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbNamHHActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(2, 2, 2)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jcbNgayHH, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jcbThangHH, 0, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jcbNamHH, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jrdCobh)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jrdKhongbh)
                        .addGap(18, 18, 18)
                        .addComponent(jlbMabh)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtextfMabh, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jcheckboxVuottuyen))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel7)
                            .addComponent(jLabel5))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jtextfDiachi)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jtextfDienthoai, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jcbNamsinh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel8)
                                        .addGap(18, 18, 18)
                                        .addComponent(jtextfTuoi, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel9)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jtextfCmnd, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE))))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel2))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jtextfTen, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jrdNam)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jrdNu))
                            .addComponent(jtextfMabn, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtextfMabn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jtextfTen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(jrdNam)
                    .addComponent(jrdNu))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 6, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jcbNamsinh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(jtextfTuoi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jtextfDienthoai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(jtextfCmnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jtextfDiachi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(jrdCobh)
                    .addComponent(jrdKhongbh)
                    .addComponent(jlbMabh)
                    .addComponent(jtextfMabh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcheckboxVuottuyen))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jcbNgayHH, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jcbThangHH, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jcbNamHH, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel12))
                .addGap(10, 10, 10))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(0, 0, 102))));
        jPanel2.setAutoscrolls(true);

        jLabel18.setText("Tiền sử sức khỏe");

        jtextaTiensu.setColumns(20);
        jtextaTiensu.setLineWrap(true);
        jtextaTiensu.setRows(5);
        jtextaTiensu.setWrapStyleWord(true);
        jtextaTiensu.addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
                jtextaTiensuAncestorAdded(evt);
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
            }
        });
        jtextaTiensu.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtextaTiensuKeyReleased(evt);
            }
        });
        jScrollPane2.setViewportView(jtextaTiensu);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel18)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2)
                .addContainerGap())
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(78, 78, 78)
                .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(0, 0, 102))));
        jPanel3.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jPanel3.setPreferredSize(new java.awt.Dimension(590, 40));

        jLabel19.setText("Phòng khám");

        jcbPhongKham.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Chọn phòng khám", "Bệnh cơ xương khớp", "Bệnh da liễu", "Bệnh mắt", "Bệnh ngoại tổng quát", "Bệnh nhiệt đới", "Bệnh nội thần kinh", "Bệnh nội tiết", "Bệnh răng hàm mặt", "Bệnh tai mũi họng", "Bệnh tiêu hoá", "Bệnh tim mạch", "Khám và chứng nhận sức khoẻ", "Ngoại thần kinh, thận niệu", "Sản phụ khoa và kế hoạch hóa gia đình" }));
        jcbPhongKham.setAutoscrolls(true);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(2, 2, 2)
                .addComponent(jLabel19)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jcbPhongKham, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(jcbPhongKham, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(0, 0, 102))));

        jLabel25.setText("Nhân viên trực");

        jtextfNhanvientruc.setEnabled(false);
        jtextfNhanvientruc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtextfNhanvientrucActionPerformed(evt);
            }
        });

        lbdate.setText("jLabel14");

        jLabel6.setText("Hôm nay là:");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addGap(18, 18, 18)
                .addComponent(lbdate)
                .addGap(163, 163, 163)
                .addComponent(jLabel25)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jtextfNhanvientruc, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
                .addGap(240, 240, 240))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel25)
                    .addComponent(jtextfNhanvientruc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbdate)
                    .addComponent(jLabel6))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButton2.setText("Nhập lại");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("Thoát");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        btnSave.setText("Lưu");
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addGap(0, 595, Short.MAX_VALUE)
                .addComponent(btnSave, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3)
                .addGap(58, 58, 58))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton3)
                    .addComponent(btnSave))
                .addContainerGap(12, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 861, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(14, 14, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(277, 277, 277))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jtextfMabnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtextfMabnActionPerformed
        // TODO add your handling code here:

    }//GEN-LAST:event_jtextfMabnActionPerformed

    private void jtextfMabnKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtextfMabnKeyReleased
        // Nhấn enter là qua ô nhập khác
        if(evt.getKeyCode() == evt.VK_ENTER){
            jtextfMabn.transferFocus();
        }
    }//GEN-LAST:event_jtextfMabnKeyReleased

    private void jtextfTenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtextfTenActionPerformed
        // Nhấn enter là qua ô nhập khác

    }//GEN-LAST:event_jtextfTenActionPerformed

    private void jtextfTenKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtextfTenKeyReleased
        // Enter cái là qua ô khác nhập
        if(evt.getKeyCode() == evt.VK_ENTER){
            jtextfTen.transferFocus(); }
    }//GEN-LAST:event_jtextfTenKeyReleased

    private void jcbNamsinhActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbNamsinhActionPerformed
        java.util.Date date = new java.util.Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyy");
        int curretYear = Integer.valueOf(format.format(date));
        int namsinh = Integer.valueOf(jcbNamsinh.getSelectedItem().toString());
        int tuoi = curretYear - namsinh;
        jtextfTuoi.setText(String.valueOf(tuoi));
    }//GEN-LAST:event_jcbNamsinhActionPerformed

    private void jtextfDiachiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtextfDiachiActionPerformed

    }//GEN-LAST:event_jtextfDiachiActionPerformed

    private void jrdNamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrdNamActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jrdNamActionPerformed

    private void jrdCobhActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrdCobhActionPerformed
        // TODO add your handling code here:
        jtextfMabh.setEnabled(true);
        jlbMabh.setEnabled(true);
        jcheckboxVuottuyen.setEnabled(true);
        jcbNgayHH.setEnabled(true);
        jcbThangHH.setEnabled(true);
        jcbNamHH.setEnabled(true);
    }//GEN-LAST:event_jrdCobhActionPerformed

    private void jrdKhongbhActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrdKhongbhActionPerformed
        // TODO add your handling code here:
        jtextfMabh.setEnabled(false);
        jlbMabh.setEnabled(false);
        jcheckboxVuottuyen.setEnabled(false);
        jcbNgayHH.setEnabled(false);
        jcbThangHH.setEnabled(false);
        jcbNamHH.setEnabled(false);
        jtextfMabh.setText("");
        jcheckboxVuottuyen.setSelected(false);
    }//GEN-LAST:event_jrdKhongbhActionPerformed

    private void jtextfMabhActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtextfMabhActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtextfMabhActionPerformed

    private void jtextfMabhKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtextfMabhKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtextfMabhKeyPressed

    private void jcheckboxVuottuyenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcheckboxVuottuyenActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jcheckboxVuottuyenActionPerformed

    private void jtextfTuoiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtextfTuoiActionPerformed

    }//GEN-LAST:event_jtextfTuoiActionPerformed

    private void jtextfCmndActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtextfCmndActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtextfCmndActionPerformed

    private void jtextaTiensuAncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_jtextaTiensuAncestorAdded

    }//GEN-LAST:event_jtextaTiensuAncestorAdded

    private void jtextaTiensuKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtextaTiensuKeyReleased
        //
    }//GEN-LAST:event_jtextaTiensuKeyReleased

    private void jtextfNhanvientrucActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtextfNhanvientrucActionPerformed

    }//GEN-LAST:event_jtextfNhanvientrucActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        jtextfMabn.setText("");
        jtextfTen.setText("");
        jtextfCmnd.setText("");
        jtextaTiensu.setText("");
        jtextfDienthoai.setText("");
        jtextfTuoi.setText("");
        jtextfDiachi.setText("");
        jtextfMabh.setText("");
        jtextfNhanvientruc.setText("");
        jrdNam.setSelected(true);
        jrdCobh.setSelected(true);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // thoát chương trình
        this.dispose();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
        // Cái này là nút thêm bệnh nhân :D
        // bắt đầu kiểm tra người dùng nhập đầy đủ chưa
        String gt="";
        String mabn=jtextfMabn.getText().trim();
        String ten=jtextfTen.getText().trim();
        String tuoi=jtextfTuoi.getText().trim();
        String dienthoai=jtextfDienthoai.getText().trim();
        String diachi=jtextfDiachi.getText().trim();
        String mabh = jtextfMabh.getText().trim();
        String cmnd = jtextfCmnd.getText().trim();
        String tiensu=jtextaTiensu.getText().trim();
        String nvtruc=jtextfNhanvientruc.getText().trim();
        
        //tạo mã bệnh nhân mới ứng với năm tháng ngày giờ phút giây hiện tại
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
        java.util.Date ma = new java.util.Date();
        String maBN = format.format(ma);
        //kết thúc tạo mã

        if(jrdNam.isSelected()){
            gt = "Nam";}
        else if(jrdNu.isSelected())
        {
            gt = "Nữ";
        }
        int bh=0;
        if(jrdCobh.isSelected())
           bh = 1;
        else if(jrdKhongbh.isSelected())
            bh = 0;
        if("".equals(kiemtraNhap())){
            try{
                DTOBenhNhan dtoBenhNhan = new DTOBenhNhan();
                dtoBenhNhan.setMaBN(maBN);
                dtoBenhNhan.setHoten(ten);
                dtoBenhNhan.setNgaysinh(jcbNamsinh.getSelectedItem().toString());
                dtoBenhNhan.setGioitinh(gt);
                dtoBenhNhan.setCMND(cmnd);
                dtoBenhNhan.setDiachi(diachi);
                dtoBenhNhan.setDienthoai(dienthoai);
                dtoBenhNhan.setBHYT(bh);
                dtoBenhNhan.setMaBH(mabh);
                dtoBenhNhan.setTiensusk(tiensu);
                
                //lay ngay hien tai
                SimpleDateFormat newformat = new SimpleDateFormat("yyyy-MM-dd");
                Calendar cal = Calendar.getInstance();
                String getStringDate = newformat.format(cal.getTime());
                java.util.Date getUtilDate = newformat.parse(getStringDate);
                Date ngayDK = new Date(getUtilDate.getTime());
                dtoBenhNhan.setNgaydangky(ngayDK);
                
//                int namHH = Integer.valueOf(jcbNamHH.getSelectedItem().toString());
//                int thangHH = Integer.valueOf(jcbThangHH.getSelectedItem().toString());
//                int ngayHH = Integer.valueOf(jcbNgayHH.getSelectedItem().toString());
//                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
//                java.util.Date date = format.parse(namHH + "-" + thangHH + "-" + ngayHH);
                Date setNgayHH = null;
                if(jrdCobh.isSelected())
                    setNgayHH = layNgayHH();
                else
                    setNgayHH = null;
                dtoBenhNhan.setNgayhethan(setNgayHH);
                int vuottuyen=0;
                if(jcheckboxVuottuyen.isSelected())
                    vuottuyen=1;
                dtoBenhNhan.setVuottuyen(vuottuyen);
                DTOPhongKham dtoPhongKham = (DTOPhongKham)jcbPhongKham.getSelectedItem();//lấy đối tượng phòng khám từ combobox phòng khám
                dtoBenhNhan.setDtoPhongKham(dtoPhongKham);
                if(bllBenhNhan.nhapBenhNhan(dtoBenhNhan))//chạy hàm nhapBenhNhan, nếu nhập thành công sẽ thông báo
                    JOptionPane.showMessageDialog(null, "Đã thêm bệnh nhân mới");
                else
                    JOptionPane.showMessageDialog(null, "Thêm không thành công");
            }
            catch(HeadlessException ex){
                JOptionPane.showMessageDialog(null, "Xay ra loi chuc nang them nguoi benh");
            } catch (ParseException ex) {
                Logger.getLogger(DangKyKhamBenh.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        else
            JOptionPane.showMessageDialog(null, kiemtraNhap());//xuất các câu thông báo nếu kiểm tra chưa hợp lệ
        // kết thúc kiểm tra ở đây

        
    }//GEN-LAST:event_btnSaveActionPerformed

    //lay han su dung cua BHYT
    private Date layNgayHH(){
        try {
            int namHH = Integer.valueOf(jcbNamHH.getSelectedItem().toString());
            int thangHH = Integer.valueOf(jcbThangHH.getSelectedItem().toString());
            int ngayHH = Integer.valueOf(jcbNgayHH.getSelectedItem().toString());
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");//định dạng kiểu ngày tháng năm
            format.setLenient(false);//không cho phép lấy ngày qua tháng sau, bắt buộc phải chọn đúng ngày
            java.util.Date date = format.parse(namHH + "-" + thangHH + "-" + ngayHH);
            Date setNgayHH = new Date(date.getTime());//đổi ngày từ java.util.Date sang java.sql.Date
            return setNgayHH;
        } catch (NumberFormatException | ParseException e) {
            return null;
        }
    }
    //kiem tra nhap
    private String kiemtraNhap(){
        String ketqua="";
//        if("".equals(jtextfMabn.getText().trim()))
//            ketqua += "Vui long nhap ma benh nhan\n";
        if("".equals(jtextfTen.getText().trim()))
            ketqua+="Vui long nhap ho ten benh nhan\n";
        if(!jrdNam.isSelected() && !jrdNu.isSelected())
            ketqua += "Cho biet gioi tinh benh nhan\n";
        if("".equals(jtextfCmnd.getText().trim()))
            ketqua += "Cho biet CMND\n";
        if("".equals(jtextfDiachi.getText().trim()))
            ketqua += "Cho biet dia chi\n";
        if(!jrdCobh.isSelected() && !jrdKhongbh.isSelected())
            ketqua += "Cho biet benh nhan co BHYT khong";
        else{
            if(jrdCobh.isSelected()){
                if("".equals(jtextfMabh.getText().trim()))
                    ketqua += "Cho biet ma BH";
            }
        }
        if(layNgayHH() == null){
            ketqua += "Ngày đã chọn không hợp lệ, vui lòng chọn lại";
        }
        return ketqua;
    }
    private void jcbNgayHHItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcbNgayHHItemStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_jcbNgayHHItemStateChanged

    private void jcbNgayHHActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbNgayHHActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jcbNgayHHActionPerformed

    private void jcbNamHHActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbNamHHActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jcbNamHHActionPerformed

    private void jtextfDienthoaiKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtextfDienthoaiKeyTyped
        char vChar = evt.getKeyChar();
        if(!(Character.isDigit(vChar)) || vChar == KeyEvent.VK_BACK_SPACE || vChar == KeyEvent.VK_DELETE)
            evt.consume();
    }//GEN-LAST:event_jtextfDienthoaiKeyTyped

    private void jtextfCmndKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtextfCmndKeyTyped
        char vChar = evt.getKeyChar();
        if(!(Character.isDigit(vChar)) || vChar == KeyEvent.VK_BACK_SPACE || vChar == KeyEvent.VK_DELETE)
            evt.consume();
    }//GEN-LAST:event_jtextfCmndKeyTyped

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(DangKyKhamBenh.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(DangKyKhamBenh.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(DangKyKhamBenh.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(DangKyKhamBenh.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new DangKyKhamBenh().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnSave;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JComboBox jcbNamHH;
    private javax.swing.JComboBox jcbNamsinh;
    private javax.swing.JComboBox jcbNgayHH;
    private javax.swing.JComboBox jcbPhongKham;
    private javax.swing.JComboBox jcbThangHH;
    private javax.swing.JCheckBox jcheckboxVuottuyen;
    private javax.swing.JLabel jlbMabh;
    private javax.swing.JRadioButton jrdCobh;
    private javax.swing.JRadioButton jrdKhongbh;
    private javax.swing.JRadioButton jrdNam;
    private javax.swing.JRadioButton jrdNu;
    private javax.swing.JTextArea jtextaTiensu;
    private javax.swing.JTextField jtextfCmnd;
    private javax.swing.JTextField jtextfDiachi;
    private javax.swing.JTextField jtextfDienthoai;
    private javax.swing.JTextField jtextfMabh;
    private javax.swing.JTextField jtextfMabn;
    private javax.swing.JTextField jtextfNhanvientruc;
    private javax.swing.JTextField jtextfTen;
    private javax.swing.JTextField jtextfTuoi;
    private javax.swing.JLabel lbdate;
    // End of variables declaration//GEN-END:variables
}
